<div class="layui-card-header layui-card">
    <span class="layui-breadcrumb" lay-filter="breadcrumb">
        <a lay-href="">首页</a>
        <a>支付订单</a>
        <a><cite>订单详情</cite></a>
    </span>
</div>
<style>
    .layui-form-label {
        width:15% !important;
        margin-left:1%;
    }
    .layui-input-inline {
        width: 33% !important;
    }
</style>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li class="layui-this">订单详情</li>
            </ul>
            <div class="layui-tab-content">
                <form class="layui-form layui-form-pane" id="layuiadmin-app-form-list">
                    <div class="layui-form-item">
                        <label class="layui-form-label">支付订单号</label>
                        <div class="layui-input-inline">
                            <input type="text" id="payOrderId" name="payOrderId" disabled="disabled" class="layui-input">
                        </div>
                        <label class="layui-form-label">商户订单号</label>
                        <div class="layui-input-inline">
                            <input type="text" id="mchOrderNo" name="mchOrderNo" disabled="disabled" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">支付金额</label>
                        <div class="layui-input-inline">
                            <input type="text" id="amount" name="amount" disabled="disabled" class="layui-input">
                        </div>
                        <label class="layui-form-label">币种</label>
                        <div class="layui-input-inline">
                            <input type="text" id="currency" name="currency" disabled="disabled" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">支付状态</label>
                        <div class="layui-input-inline">
                            <input type="text" id="state" name="state" disabled="disabled" class="layui-input">
                        </div>
                        <label class="layui-form-label">客户端IP</label>
                        <div class="layui-input-inline">
                            <input type="text" id="clientIp" name="clientIp" disabled="disabled" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">设备</label>
                        <div class="layui-input-inline">
                            <input type="text" id="device" name="device" disabled="disabled" class="layui-input">
                        </div>
                        <label class="layui-form-label">商品标题</label>
                        <div class="layui-input-inline">
                            <input type="text" id="title" name="title" disabled="disabled" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">商品描述</label>
                        <div class="layui-input-inline">
                            <input type="text" id="body" name="body" disabled="disabled" class="layui-input">
                        </div>
                        <label class="layui-form-label">渠道用户</label>
                        <div class="layui-input-inline">
                            <input type="text" id="channelUser" name="channelUser" disabled="disabled" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">渠道商户ID</label>
                        <div class="layui-input-inline">
                            <input type="text" id="channelMchId" name="channelMchId" disabled="disabled" class="layui-input">
                        </div>
                        <label class="layui-form-label">渠道订单号</label>
                        <div class="layui-input-inline">
                            <input type="text" id="channelOrderNo" name="channelOrderNo" disabled="disabled" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">商户费率(%)</label>
                        <div class="layui-input-inline">
                            <input type="text" id="mchRate" name="mchRate" disabled="disabled" class="layui-input">
                        </div>
                        <label class="layui-form-label">平台利润</label>
                        <div class="layui-input-inline">
                            <input type="text" id="platProfit" name="platProfit" disabled="disabled" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">渠道费率(%)</label>
                        <div class="layui-input-inline">
                            <input type="text" id="channelRate" name="channelRate" disabled="disabled" class="layui-input">
                        </div>
                        <label class="layui-form-label">渠道成本</label>
                        <div class="layui-input-inline">
                            <input type="text" id="channelCost" name="channelCost" disabled="disabled" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">商户ID</label>
                        <div class="layui-input-inline">
                            <input type="text" id="mchId" name="mchId" disabled="disabled" class="layui-input">
                        </div>
                        <label class="layui-form-label">应用ID</label>
                        <div class="layui-input-inline">
                            <input type="text" id="appId" name="appId" disabled="disabled" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">渠道ID</label>
                        <div class="layui-input-inline">
                            <input type="text" id="channelId" name="channelId" disabled="disabled" class="layui-input">
                        </div>
                        <label class="layui-form-label">通道ID</label>
                        <div class="layui-input-inline">
                            <input type="text" id="passageId" name="passageId" disabled="disabled" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">是否退款</label>
                        <div class="layui-input-inline">
                            <input type="text" id="isRefund" name="isRefund" disabled="disabled" class="layui-input">
                        </div>
                        <label class="layui-form-label">退款次数</label>
                        <div class="layui-input-inline">
                            <input type="text" id="refundTimes" name="refundTimes" disabled="disabled" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">退款金额</label>
                        <div class="layui-input-inline">
                            <input type="text" id="successRefundAmount" name="successRefundAmount" disabled="disabled" class="layui-input">
                        </div>
                        <label class="layui-form-label">错误码</label>
                        <div class="layui-input-inline">
                            <input type="text" id="errCode" name="errCode" disabled="disabled" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">错误描述</label>
                        <div class="layui-input-inline">
                            <input type="text" id="errMsg" name="errMsg" disabled="disabled" class="layui-input">
                        </div>
                        <label class="layui-form-label">扩展参数1</label>
                        <div class="layui-input-inline">
                            <input type="text" id="param1" name="param1" disabled="disabled" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">扩展参数2</label>
                        <div class="layui-input-inline">
                            <input type="text" id="param2" name="param2" disabled="disabled" class="layui-input">
                        </div>
                        <label class="layui-form-label">通知地址</label>
                        <div class="layui-input-inline">
                            <input type="text" id="notifyUrl" name="notifyUrl" disabled="disabled" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">失效时间</label>
                        <div class="layui-input-inline">
                            <input type="text" id="expireTime" name="expireTime" disabled="disabled" class="layui-input">
                        </div>
                        <label class="layui-form-label">成功时间</label>
                        <div class="layui-input-inline">
                            <input type="text" id="paySuccTime" name="paySuccTime" disabled="disabled" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">创建时间</label>
                        <div class="layui-input-inline">
                            <input type="text" id="createTime" name="createTime" disabled="disabled" class="layui-input">
                        </div>
                        <label class="layui-form-label">更新时间</label>
                        <div class="layui-input-inline">
                            <input type="text" id="updateTime" name="updateTime" disabled="disabled" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">扩展参数</label>
                        <div class="layui-input-inline">
                            <input type="text" id="extra" name="extra" disabled="disabled" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block" style="margin-left: 12px">
                            <a class="layui-btn backBtn" onclick="back()">返回</a>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['table','util','admin', 'form'], function(){
        var table = layui.table
        ,$ = layui.$
        ,form = layui.form
        ,admin = layui.admin
        ,element = layui.element;

        element.render('breadcrumb', 'breadcrumb');//渲染导航信息

        var payOrderId = layui.router().search.id;
        admin.req({
            type: 'get',
            url: layui.setter.baseUrl + '/pay_order/get',
            data: {
                payOrderId : payOrderId
            },
            error: function(err){
                layer.alert(JSON.stringify(err.field), {
                    title: '错误提示'
                })
            },
            success: function(res){
                if(res.code == 0){
                    data =res.data;

                    var state = data.state==0?"订单生成":data.state==1?"支付中":data.state==2?"支付成功":data.state==3?"处理完成":data.state==4?"已退款":"发生错误";

                    $('#payOrderId').val(res.data.payOrderId);
                    $('#mchId').val(res.data.mchId);
                    $('#appId').val(res.data.appId);
                    $('#mchOrderNo').val(res.data.mchOrderNo);
                    $("#state").val(state);
                    $('#channelId').val(res.data.channelId);
                    $('#passageId').val(res.data.passageId);
                    $('#mchRate').val(res.data.mchRate);
                    $('#platProfit').val(res.data.platProfit/100);
                    $('#channelRate').val(res.data.channelRate);
                    $('#channelCost').val(res.data.channelCost/100);
                    if(res.data.isRefund == 0) {
                        $('#isRefund').val("否");
                    }else if(res.data.isRefund == 1) {
                        $('#isRefund').val("是");
                    }
                    $('#refundTimes').val(res.data.refundTimes);
                    $('#successRefundAmount').val(res.data.successRefundAmount);
                    $('#amount').val(res.data.amount/100);
                    if(res.data.currency == "cny") {
                        $('#currency').val("人民币");
                    }
                    $('#clientIp').val(res.data.clientIp);
                    $('#device').val(res.data.device);
                    $('#title').val(res.data.title);
                    $('#body').val(res.data.body);
                    $('#extra').val(res.data.extra);
                    $('#channelUser').val(res.data.channelUser);
                    $('#channelMchId').val(res.data.channelMchId);
                    $('#channelOrderNo').val(res.data.channelOrderNo);
                    $('#errCode').val(res.data.errCode);
                    $('#errMsg').val(res.data.errMsg);
                    $('#param1').val(res.data.param1);
                    $('#param2').val(res.data.param2);
                    $('#notifyUrl').val(res.data.notifyUrl);
                    if(res.data.expireTime != "" && res.data.expireTime != null) {
                        $('#expireTime').val(layui.util.toDateString(res.data.expireTime));
                    }
                    if(res.data.paySuccTime != "" && res.data.paySuccTime != null) {
                        $('#paySuccTime').val(layui.util.toDateString(res.data.paySuccTime));
                    }
                    if(res.data.createTime != "" && res.data.createTime != null) {
                        $('#createTime').val(layui.util.toDateString(res.data.createTime));
                    }
                    if(res.data.updateTime != "" && res.data.updateTime != null) {
                        $('#updateTime').val(layui.util.toDateString(res.data.updateTime));
                    }
                }
            }
        })

    })

    function back(){
        location.href = layui.setter.baseLocal + "order/pay/index";
    }
</script>
